package test;
import it.sauronsoftware.cron4j.Scheduler;

import java.text.DateFormat;
import java.text.SimpleDateFormat;


public class Quickstart {

	public Quickstart() {}
	
	public static void main( String[] args) {
		
		final DateFormat df = new SimpleDateFormat( "YYYY-MM-dd hh:mm:ss");
		
		// Creates a Scehduler  instance.
		Scheduler s = new Scheduler();
		
		// Scheduler a once-a-minute task.
		s.schedule("56 * * * *",  new Runnable() {
			public void run() {
				System.out.println( "Another minute ticked away...");
				System.out.println( "currentTime = " + df.format( System.currentTimeMillis()));
//				File file = new File( "d:\\abc.txt.");
//				try {
//					file.createNewFile();
//				} catch (IOException e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}
			}
		});
		
		// Starts the scheduler.
		s.start();
		
		// Will run for ten minutes.
		try {
			Thread.sleep( 1000L * 60L * 10L);

		} catch( InterruptedException e) {
			s.stop();
		}
		
		// Stops the scheduler.
		s.stop();
		
	}

}
